

***Note: replicators should set directory to open data 
*cd ""

*Also note data are in .sav format, need to be put in stata

********** FIGURE 2d: Ethnoracial Attitudes, Latin America **********

*Based on Latino barometer 2009-10, see appendix. Original dataset: http://www.latinobarometro.org/latContents.jsp

clear all
use Latinobarometro.dta

 label var D "Discrimination"
 label var PD "Perceptions of discrimination"


gen South=0
replace  South=1 if country=="Argentina" | country=="Bolivia" | country=="Brazil" | country=="Chile" | country=="Colombia" | country=="Ecuador" | country=="Guyana" | country=="Paraguay" | country=="Peru" | country=="Suriname" | country=="Uruguay" | country=="Venezuela"


gen Central=0
replace Central=1 if country=="Belize" | country=="Costa Rica" | country=="El Salvador" | country=="Guatemala" | country=="Honduras" | country=="Nicaragua" | country=="Panama"


gen Carribean=0
replace Carribean=1 if country=="Antigua and Barbuda" | country=="Bahamas" | country=="Barbados" | country=="Cuba" | country=="Dominica" | country=="Dominican Republic" | country=="Grenada" | country=="Haiti" | country=="Jamaica" | country=="Saint Kitts and Nevis" | country=="Saint Lucia" | country=="Saint Vincent and the Grenadines" | country=="Trinidad and Tobago"

gen Area=.
replace Area=1 if South==1
replace Area=2 if Central==1
replace Area=3 if Carribean==1


label variable Area "Continent"
la def aria  1 "South" 2 "Central"  3 "Carribean", modify
la val Area aria

 grstyle init
 grstyle set legend 2,  nobox
 grstyle set size 8pt: tick_label key_label
 grstyle set size 12pt: heading
 grstyle set size 10pt: subheading axis_title 
 grstyle set graphsize 13cm 11.5cm
 

reg    PD D
ereturn list
loc N6= e(N)
local b= round(_b[D],.001)
local t = _b[D]/_se[D]
local p =round(2*ttail(e(df_r),abs(`t')),.001)


  graph twoway    (lfitci PD  D,   lcol(black)  lwidth(medthick) ciplot(rline) blpattern(dash) acolor(black%65) )     (scatter PD  D if Area==1,       mcolor(black)   msymbol(d))   (scatter PD  D if Area==2,   mcolor(black)    msymbol(S)) (scatter PD  D if Area==3,   mcolor(black)    msymbol(o)), name(a, replace)    legend(position(12) rows(1)  order(3 "South" 4 "Central" 5 "Carribean" ) span) ytitle("Perceptions of discrimination")    xtitle("Discriminatory attitudes") note("Author's computation based on the Latinobarometro." "Plot country-round pairwise correlation. {&rho} = `b' | {it:p-value} = `p' | {it:N} = `N6'." ,size(vsmall) span) subtitle("{bf: Ethnoracial attitudes in Latin America}") 
  graph export "Graph/Figure2d.tif", replace 
  graph save "Graph/Figure2d", replace
